package edu.kpi.pzks2.ui.dialogs;

//import edu.kpi.pzks2.ui.dialogs.SimulationDialog.TaskQueueRadioButtonEnum;
//import gui.toolbar.TaskToolBar;
//
//import java.awt.BorderLayout;
//import java.awt.GridLayout;
//import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;
//import java.beans.PropertyChangeEvent;
//import java.beans.PropertyChangeListener;
//
//import javax.swing.ButtonGroup;
//import javax.swing.JDialog;
//import javax.swing.JLabel;
//import javax.swing.JOptionPane;
//import javax.swing.JPanel;
//import javax.swing.JRadioButton;
//import javax.swing.JTextField;
//
//public class SimulationDialog extends JDialog implements ActionListener,
//	PropertyChangeListener {	
//	private static final long serialVersionUID = 1L;
//	
//	private enum TaskQueueRadioButtonEnum {TASK_QUEUE1, TASK_QUEUE2, TASK_QUEUE3};
//	private enum ProcQueueRadioButtonEnum {PROC_QUEUE1, PROC_QUEUE2};
//	private enum ChannelModeRadioButtonEnum {DUPLEX, SIMPLEX};
//	private enum PackageModeRadioButtonEnum {PACKAGES, MESSAGE};
//	
//	private TaskQueueRadioButtonEnum selectedTaskQueue;
//	private ProcQueueRadioButtonEnum selectedProcQueue;
//	private ChannelModeRadioButtonEnum selectedChannelMode;
//	private PackageModeRadioButtonEnum selectedPackageMode;
//	
//	private JTextField channelCountTextField;
//	private JTextField linkSpeedTextField;
//	private JTextField processorsSpeedTextField;
//	
//	private JLabel channelCountLabel;
//	private JLabel linkSpeedLabel;
//	private JLabel processorsSpeedLabel;
//	private JLabel packageModeLabel;
//	private JLabel channelModeLabel;
//	private JLabel taskQueueLabel;
//	private JLabel procQueueLabel;
//	
//	private JRadioButton taskQueue1RadioButton;
//	private JRadioButton taskQueue2RadioButton;
//	private JRadioButton taskQueue3RadioButton;
//	
//	private JRadioButton procQueue1RadioButton;
//	private JRadioButton procQueue2RadioButton;
//	
//	private JRadioButton packageMode1RadioButton;
//	private JRadioButton packageMode2RadioButton;
//	
//	private JRadioButton channelMode1RadioButton;
//	private JRadioButton channelMode2RadioButton;
//	
//	private String btnString1 = "Enter";
//	private String btnString2 = "Cancel";
//	
//	private static String taskQueueString1 = "Task queue 1";
//	private static String taskQueueString2 = "Task queue 2";
//	private static String taskQueueString3 = "Task queue 3";
//	
//	private static String procQueueString1 = "Proc queue 1";
//	private static String procQueueString2 = "Proc queue 2";	
//	
//	private static String packageModeString1 = "Packages";
//	private static String packageModeString2 = "Message";
//	
//	private static String channelModeString1 = "Simplex";
//	private static String channelModeString2 = "Duplex";
//	
//	JOptionPane optionPane;
//	
//	public SimulationDialog() {
//		super();
//		this.setTitle("Simulation params");
//		
//		Object[] options = {btnString1, btnString2};
//		
//		channelCountTextField = new JTextField(2);
//		channelCountLabel = new JLabel("Channel count");
//		
//		JPanel pane1 = new JPanel(new BorderLayout());
//		pane1.add(channelCountLabel, BorderLayout.WEST);
//		pane1.add(channelCountTextField, BorderLayout.EAST);
//		
//		linkSpeedTextField = new JTextField(3);
//		linkSpeedLabel = new JLabel("Link speed");
//		
//		JPanel pane2 = new JPanel(new BorderLayout());
//		pane2.add(linkSpeedLabel, BorderLayout.WEST);
//		pane2.add(linkSpeedTextField, BorderLayout.EAST);
//			
//		processorsSpeedTextField = new JTextField(3);
//		processorsSpeedLabel = new JLabel("Processors speed");
//		
//		JPanel pane3 = new JPanel(new BorderLayout());
//		pane3.add(processorsSpeedLabel, BorderLayout.WEST);
//		pane3.add(processorsSpeedTextField, BorderLayout.EAST);
//		
//		taskQueue1RadioButton = new JRadioButton(taskQueueString1);
//		taskQueue1RadioButton.setSelected(true);
//		taskQueue1RadioButton.addActionListener(getRadioButtonListener());
//		taskQueue1RadioButton.setActionCommand(taskQueueString1);
//		
//		taskQueue2RadioButton = new JRadioButton(taskQueueString2);
//		taskQueue2RadioButton.addActionListener(getRadioButtonListener());
//		taskQueue2RadioButton.setActionCommand(taskQueueString2);
//		
//		taskQueue3RadioButton = new JRadioButton(taskQueueString3);
//		taskQueue3RadioButton.addActionListener(getRadioButtonListener());
//		taskQueue3RadioButton.setActionCommand(taskQueueString3);
//		    
//	    JPanel taskQueueRadioPanel = new JPanel(new GridLayout(0, 1));
//	    taskQueueRadioPanel.add(taskQueue1RadioButton);
//	    taskQueueRadioPanel.add(taskQueue2RadioButton);
//	    taskQueueRadioPanel.add(taskQueue3RadioButton);
//        
//	    taskQueueLabel = new JLabel("Select task queue");
//		JPanel pane4 = new JPanel(new BorderLayout());
//		pane4.add(taskQueueLabel, BorderLayout.WEST);
//		pane4.add(taskQueueRadioPanel, BorderLayout.EAST);
//		
//		procQueue1RadioButton = new JRadioButton(procQueueString1);
//		procQueue1RadioButton.setSelected(true);
//		procQueue1RadioButton.addActionListener(getRadioButtonListener());
//		procQueue1RadioButton.setActionCommand(procQueueString1);
//		
//		procQueue2RadioButton = new JRadioButton(procQueueString2);
//		procQueue2RadioButton.addActionListener(getRadioButtonListener());
//		procQueue2RadioButton.setActionCommand(procQueueString2);
//		
//	    JPanel procQueueRadioPanel = new JPanel(new GridLayout(0, 1));
//	    procQueueRadioPanel.add(procQueue1RadioButton);
//	    procQueueRadioPanel.add(procQueue2RadioButton);
//	    
//	    procQueueLabel = new JLabel("Select processors queue");
//		JPanel pane5 = new JPanel(new BorderLayout());
//		pane5.add(procQueueLabel, BorderLayout.WEST);
//		pane5.add(procQueueRadioPanel, BorderLayout.EAST);
//
//		packageMode1RadioButton = new JRadioButton(packageModeString1);
//		packageMode1RadioButton.setSelected(true);
//		packageMode1RadioButton.addActionListener(getRadioButtonListener());
//		packageMode1RadioButton.setActionCommand(packageModeString1);
//		
//		packageMode2RadioButton = new JRadioButton(packageModeString2);
//		packageMode2RadioButton.addActionListener(getRadioButtonListener());
//		packageMode2RadioButton.setActionCommand(packageModeString2);
//		
//	    JPanel packageModeRadioPanel = new JPanel(new GridLayout(0, 1));
//	    packageModeRadioPanel.add(packageMode1RadioButton);
//	    packageModeRadioPanel.add(packageMode2RadioButton);
//	    
//		packageModeLabel = new JLabel("Select package mode");
//		JPanel pane6 = new JPanel(new BorderLayout());
//		pane6.add(packageModeLabel, BorderLayout.WEST);
//		pane6.add(packageModeRadioPanel, BorderLayout.EAST);		
//		
//		channelMode1RadioButton = new JRadioButton(channelModeString1);
//		channelMode1RadioButton.setSelected(true);
//		channelMode1RadioButton.addActionListener(getRadioButtonListener());
//		channelMode1RadioButton.setActionCommand(channelModeString1);
//		
//		channelMode2RadioButton = new JRadioButton(channelModeString2);
//		channelMode2RadioButton.addActionListener(getRadioButtonListener());
//		channelMode2RadioButton.setActionCommand(channelModeString2);
//		
//	    JPanel channelModeRadioPanel = new JPanel(new GridLayout(0, 1));
//	    channelModeRadioPanel.add(channelMode1RadioButton);
//	    channelModeRadioPanel.add(channelMode2RadioButton);
//	    
//	    channelModeLabel = new JLabel("Select channel mode");
//		JPanel pane7 = new JPanel(new BorderLayout());
//		pane6.add(channelModeLabel, BorderLayout.WEST);
//		pane6.add(channelModeRadioPanel, BorderLayout.EAST);
//		
//		Object[] array = {pane1, pane2,
//			pane3, pane4,
//			pane5, pane6, pane7};
//		
//		optionPane = new JOptionPane(array,
//		          JOptionPane.QUESTION_MESSAGE,
//		          JOptionPane.YES_NO_OPTION,
//		          null,
//		          options,
//		          options[0]);
//		
//		setContentPane(optionPane);
//			
//		optionPane.addPropertyChangeListener(this);
//		pack();
//	}
//	
//	public void actionPerformed(ActionEvent e) {
//		optionPane.setValue(btnString1);
//	}
//	
//	public void propertyChange(PropertyChangeEvent e) {
//	
//		if (isVisible() && (e.getSource() == optionPane)) {
//		Object value = optionPane.getValue();
//		
//		if (value == JOptionPane.UNINITIALIZED_VALUE) {
//			//ignore reset
//			return;
//		}
//	
//		if (btnString1.equals(value)) {				
//			try {
//				String channelCount = channelCountTextField.getText();
//				String linkSpeed = linkSpeedTextField.getText();
//				String procSpeed = processorsSpeedTextField.getText();				
//				
//				int simulatorChannelCount = Integer.parseInt(channelCount);
//				int simulatorLinkSpeed = Integer.parseInt(linkSpeed);
//				int simulatorProcSpeed = Integer.parseInt(procSpeed);
//				
//				if (simulatorChannelCount <= 0 || simulatorLinkSpeed <= 0 || 
//						simulatorProcSpeed <= 0) {
//					throw new Exception();
//				}
//				
//				// implement radiobuttons
//				System.out.println("simulatorChannelCount " + simulatorChannelCount +
//						" simulatorLinkSpeed " + simulatorLinkSpeed +
//						" simulatorProcSpeed "+ simulatorProcSpeed);
//				
//				clearAndHide();
//			} catch (Exception exc) {
//				System.out.println("Show alert, that smth is wrong =)");
//			}
//		} else {
//			clearAndHide();
//		}
//		optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
//		}
//	}
//	
//	public void clearAndHide() {
//		channelCountTextField.setText(null);
//		linkSpeedLabel.setText(null);
//		processorsSpeedLabel.setText(null);		
//		packageModeLabel.setText(null);
//		channelModeLabel.setText(null);
//		taskQueueLabel.setText(null);
//		procQueueLabel.setText(null);
//		
//		setVisible(false);
//	}
//
//    public ActionListener getRadioButtonListener() {
//        return new ActionListener() {
//            public void actionPerformed(ActionEvent e) {
//            	System.out.println(e.getActionCommand() + " selected");
//            	
//            	// task queue
//            	if (e.getActionCommand().equals(taskQueueString1)) {
//            		selectedTaskQueue = TaskQueueRadioButtonEnum.TASK_QUEUE1;
//            		return;
//            	}
//            	if (e.getActionCommand().equals(taskQueueString2)) {
//            		selectedTaskQueue = TaskQueueRadioButtonEnum.TASK_QUEUE2;
//            		return;
//            	}
//            	if (e.getActionCommand().equals(taskQueueString3)) {
//            		selectedTaskQueue = TaskQueueRadioButtonEnum.TASK_QUEUE3;
//            		return;
//            	}
//            	
//            	// proc queue
//            	if (e.getActionCommand().equals(procQueueString1)) {
//            		selectedProcQueue = ProcQueueRadioButtonEnum.PROC_QUEUE1;
//            		return;
//            	}
//            	if (e.getActionCommand().equals(procQueueString2)) {
//            		selectedProcQueue = ProcQueueRadioButtonEnum.PROC_QUEUE2;
//            		return;
//            	}
//            	
//            	// package mode
//            	if (e.getActionCommand().equals(packageModeString1)) {
//            		selectedPackageMode = PackageModeRadioButtonEnum.PACKAGES;
//            		return;
//            	}
//            	if (e.getActionCommand().equals(packageModeString2)) {
//            		selectedPackageMode = PackageModeRadioButtonEnum.MESSAGE;
//            		return;
//            	}
//            	
//            	// channel mode
//            	if (e.getActionCommand().equals(channelModeString1)) {
//            		selectedChannelMode = ChannelModeRadioButtonEnum.SIMPLEX;
//            		return;
//            	}
//            	if (e.getActionCommand().equals(channelModeString2)) {
//            		selectedChannelMode = ChannelModeRadioButtonEnum.DUPLEX;
//            		return;
//            	}
//            }
//        };
//    }
//}
